package cn.yunhe.shiro_demo.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class Demo {

    @RequestMapping("/login")
    public String toLogin(String username,String password) {
        UsernamePasswordToken token=new UsernamePasswordToken(username,password);
        Subject subject= SecurityUtils.getSubject();
        try {
            subject.login(token);
        } catch (Exception e) {
            return "login";
        }
        return "show";
    }


    @RequestMapping("/update")
    public String update(){
        return "update";
    }

    @RequestMapping("/add")
    public String add(){
        return "add";
    }


}
